<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue生命周期</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <div>{{msg}}</div>
    <button @click="destroyHandler">销毁vue实例</button>
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello vue'
      },
      methods: {
        findAll() {
          console.log('ajax请求');
        },
        clickHandler() {
          this.msg = "改变了msg"
        },
        destroyHandler() {
          this.$destroy();
        }
      },
      beforeCreate() {
        console.log('beforeCteate');
      },
      created() {
        this.findAll()
        console.log('created');
      },
      beforeMount() {
        console.log('beforeMount');
      },
      mounted() {
        console.log('mounted');
      },
      beforeUpdate(){
        console.log('beforeUpdate');
      },
      updated() {
        console.log('updated');
      },
      beforeDestroy() {
        console.log('beforeDestroy');
      },
      destroyed() {
        console.log('destroyed');
      }
    })
  </script>
</body>
</html>